function linearAnimation(ele, target) {
    clearInterval(interId);
    interId = setInterval(function() {
        // x:小盒距离 大盒子的距离 和 target目标距离
        // x800|0 == target800|0 ,,清空定时器
        // x0-799 > target 0, 向左  点击向左 moveAnimation(small,0)
        // x0-799 <target 800 向右  点击向右 moveAnimation(small,800)
        var x = ele.offsetLeft; //400,800 0-500
        if (x == target) {
            clearInterval(interId);
        } else if (x > target) {
            x -= 15; //向右时的速度
            x = x < target ? target : x;
            ele.style.left = x + 'px';
        } else if (x < target) {
            x += 15; //向左时的速度
            x = x > target ? target : x;
            ele.style.left = x + 'px';
        }
    }, 20)
}


var interId;


    var ul1 = document.getElementsByClassName('swiperBox')[0];
    var li1 = document.getElementsByClassName('clients');
    var box1 = document.getElementsByClassName('box')[0];
    var prev = document.getElementsByClassName('left')[0];
    var next = document.getElementsByClassName('right')[0];
    var index = 0;
    var jd1 = 0;
    var jianxie1;

    function fun1() {
        jianxie1 = setInterval(function() {
            index++;
            jd1++;
            if (index >= li1.length) {
                index = 1;
                ul1.style.left = 0 + 'px';
            }
            linearAnimation(ul1, -index * li1[0].offsetWidth);
            console.log(ul1, -index * li1[0].offsetWidth);
            // ul1.style.left = -index * li1[0].offsetWidth + 'px';
            // console.log(jd1);
        }, 5000);
    }
    fun1();
    box1.onmouseover = function() {
        clearInterval(jianxie1);
    }
    box1.onmouseout = function() {
        fun1();
    }
    next.onclick = function() {
        index++;
        jd1++;
        if (index >= li1.length) {
            index = 1;
            ul1.style.left = 0 + 'px';
        }
        linearAnimation(ul1, -index * li1[0].offsetWidth);
    }
    prev.onclick = function() {

        jd1--;
        if (index <= 0) {
            index = li1.length - 1;
            ul1.style.left = -index * li1[0].offsetWidth + 'px';
        }
        index--;
        linearAnimation(ul1, -index * li1[0].offsetWidth);
    }